package com.example.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
public class UserController {

    @RequestMapping("/index.html")
    public String index() {
        // 返回视图名
        return "index";
    }

    @RequestMapping("/test.html")
    public String submitUser(@RequestParam("userCode") String userCode, Model model) {
        // 在控制台输出用户编码
        System.out.println("从前台获取的用户编码为: " + userCode);

        // 将用户数据添加到模型中
        model.addAttribute("userCode",userCode);

        // 返回结果页面
        return "success";
    }
}
